package jj.rmirm.gui;

import javax.swing.JTextArea;

import jj.rmirm.interfaces.LogDisplayObserver;

public class LogDisplay implements LogDisplayObserver{

	public LogDisplay(JTextArea logField) {
		this.logField = logField;
	}
	
	private void add(String message) {
		if(!message.equals(lastMessage)) {
			logField.insert(Timer.getTime() + " " + message + "\n", 0);
			lastMessage = message;
		}	
	}
	
	public void clear() {
		logField.setText("");
	}
	
	@Override
	public void display(String message) {
		this.add(message);
	}
	
	private JTextArea logField;
	private String lastMessage = "";
}
